latex
libraries are installed, beautiful pdfs can be generated latex
style.
- You can click in the Notebook Name area and rename your notebook
- Your notebook is saved to the directory you started this server from (as a general rule though I download the notebook at intervals in addition to saving it just in case)
- To download the notebook, go to the Menu bar -> File -> Download As -> IPython Notebook (.ipynb) (if you do this you will see you can actually download in many different formats)
- In the toolbar you can add a new cell with the +, run the notebook (the triangle button - might look different in your notebook like a triangle with a line after it)
- Cell type defaults to Code. You can change this to Markdown if you want to take notes (markdown is it's own language for which you can find guides). Markdown is what all the text here is written in, so double click on this text to see the raw markdown. Also, for whatever reason you can embed any html you want (good way to include pics). Aaaaaand, LaTeX equations seem to render just fine with some exceptions.
- Code cell types are grey
- Most importantly, to run a cell hit the run button in toolbar or just type Shift-Enter (try!)
In [ ]:
Mode | What | Shortcut |
---|---|---|
Command (Press Esc to enter) |
Run cell | Shift-Enter |
Command | Add cell below | B |
Command | Add cell above | A |
Command | Delete a cell | d-d |
Command | Turn code cell to markdown cell | M |
Command | Turn markdown cell to code cell | Y |
Command | Go into edit mode | Enter |
Edit (Press Enter to go into a cell) |
Run cell | Shift-Enter |
Edit | Indent | Clrl-] |
Edit | Unindent | Ctrl-[ |
Edit | Comment/uncomment section toggle | Ctrl-/ |
Edit | Function introspection | Tab |
Convert the next cell (a code cell) into markdown (Esc
to make sure you're in command mode and M
for markdown) (Don't forget to hit the Shift-Enter
shortcut to run a cell):
In [ ]:
# turn this comment from code to a heading 1 (h1)
This sentence is one cell (a markdown cell) so please add a new cell below this one (Esc
to make sure you're in command mode and B
for below).
Comment/not comment toggle. Run the cell with Shift-Enter
. Next, uncomment the second line of code in the following code cell (Ctrl-/
which is Ctrl
and /
together):
In [ ]:
library(ggplot2)
# mtcars$am <- factor(mtcars$am)
ggplot(mtcars, aes(x = mpg, y = hp, color = am)) + geom_point()
In [ ]:
#### OK, change this cell to markdown to see some examples (you'll recognize this if you speak markdown)
# This will be Heading1
1. first thing
* second thing
* third thing
A horizontal rule:
---
> Indented text
Code snippet:
```r
df <- data.frame()
```
LaTeX inline equation:
$\Delta =\sum_{i=1}^N w_i (x_i - \bar{x})^2$
LaTeX table:
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
HTML:
<img src='http://www.elm.org/wp-content/uploads/2014/05/gold-star.jpg' alt="You get a gold star" width="42" height="42" align="left">
In [ ]:
paste0(1:10)
print(sprintf("Your current R version is %s", R.version.string))
As you can see on your jupyter homepage you can open up any notebook
NB: You can return to the homepage by clicking the Jupyter icon in the very upper left corner at any time
You can also Upload a notebook (button on upper right)
As well as start a new notebook with a specific kernel (button to the right of Upload)
So, what's that number after In
or Out
? That's the order of running this cell relative to other cells (useful for keeping track of what order cells have been run). When you save this notebook that number along with any output shown will also be saved. To reset a notebook go to Cell -> All Output -> Clear and then Save it.
You can do something like this to render a publicly available notebook on github statically (this I do as a backup for presentations and course stuff):
http://nbviewer.jupyter.org/github/<username>/<repo name>/blob/master/<notebook name>.ipynb
like:
http://nbviewer.jupyter.org/github/michhar/rpy2_sample_notebooks/blob/master/TestingRpy2.ipynb
Also, you can upload or start a new interactive, free notebook by going here:
https://tmpnb.org
Free tier account with Azure Machine Learning Studio (now has R-flavored notebooks)
The nifty thing about Jupyter notebooks (and the .ipynb files which you can download and upload) is that you can share these. They are just written in JSON language. I put them up in places like GitHub and point people in that direction.
Some people (like this guy who misses the point I think) really dislike notebooks, but they are really good for what they are good at - sharing code ideas plus neat notes and stuff in dev, teaching interactively, even chaining languages together in a polyglot style. And doing all of this on github works really well (as long as you remember to always clear your output before checking in - version control can get a bit crazy otherwise).
In [ ]:
# first, let's install some packages to play with
# replace lib string with your local library path
install.packages(c("ggplot2"),
repos = "http://cloud.r-project.org",
lib = "C:/Users/michhar/Documents/R/win-library/3.2")
In [ ]:
# tab completion and introspection
ggplot2::q # hit tab at end
plot() # place cursor in () and tab
In [ ]:
# help!
library(rjson)
?fromJSON
In [ ]:
# My feeble attempt at debugging - your mission if you choose to accept it is to figure this out
#library(htmlwidgets)
#fname = 'tmp.html'
options(error = browser())
f <- function(a) g(a)
g <- function(b) h(b)
h <- function(c) i(c)
i <- function(d) "a" + d
f(10)
t <- traceback()
#saveWidget(t, file = fname, selfcontained = F)
#IRdisplay::display_html(paste("<iframe src=' ", fname, " ' width = 100% height = 400>"))
Created by a Microsoft Employee.
The MIT License (MIT)
Copyright (c) 2016 Micheleen Harris
In [ ]: